const ms = require('../../mongoDB/db.js')
const Schema = ms.Schema;

const userSchema = new Schema({
  account: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true
  },
  role: {
    type: Number,
    default: 10
  },
  nickName: {
    type: String    
  },
  sex: {
    type: Number    
  },
  job: {
    type: String    
  },
  label: {
    type: String    
  },
  birthday: {
    type: String    
  },
  address: {
    type: String    
  },
  name: {
    type: String    
  },
  introduce: {
    type: String    
  },
  avatar: {
    type: String    
  },
  tags: {
    type: Array    
  },
  skill: {
    type: Array    
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })


const dataSchema = new Schema({
  account: {
    type: String  
  },
  qd: {
    type: Number
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })

const noteSchema = new Schema({
  user: {
    type: String,
    required: true
  },
  title: {
    type: String,
    required: true
  },
  content: {
    type: String,
    required: true
  },
  state: {
    type: Number,
    default: 0
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })


const skillbagSchema = new Schema ({
  _id: {
    type: String,
    required: true
  },
  classBag: {
    type: Array    
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })




const testUserSchema = new Schema ({
  username: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true    
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })



const tempTypeSchema = new Schema ({
  key: {
    type: String,
    required: true
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })


const tempListSchema = new Schema ({
  title: {
    type: String,
    required: true
  },
  type: {
    type: String,
    required: true
  },
  tags: {
    type: Array    
  },
  remarks: {
    type: String
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })



const tempComDataSchema = new Schema({
  parentId: {
    type: String,
    required: true
  },
  content: {
    type: String
  }
}, { timestamps: { createdAt: 'created', updatedAt: 'updated' } })

module.exports = {
  User: ms.model('user', userSchema),
  Data: ms.model('data', dataSchema),
  Note: ms.model('note', noteSchema),
  Skillbag: ms.model('skillbag', skillbagSchema),
  TestUser: ms.model('testUser', testUserSchema),
  TempType: ms.model('tempType', tempTypeSchema),
  TempList: ms.model('tempList', tempListSchema),
  TempComData: ms.model('tempComData', tempComDataSchema),
};